package com.resolution.dietaryassessment.view.chronic.model;

import android.content.Context;

import com.resolution.dietaryassessment.R;
import com.resolution.dietaryassessment.listener.MyListener;

import java.util.List;

/**
 *  @author By Resolusion
 *  @Title: ProgressPointAdapter
 *  @Date: 2020/3/26
 *  @Time: 13:08
 *  @email res01ution@foxmail.com
 */
public class ProgressPointAdapter extends ParentAdapter<SubjectInfo> {

    private SubjectInfo subjectInfo;
    private ProgressPointView mProgressPointView;

    public ProgressPointAdapter(List<SubjectInfo> mDataSource, Context mContext) {
        super(mDataSource, mContext);
    }

    /**
     *
     * @param mDataSource 数据源
     * @param mContext
     * @param resID 自定义item布局
     */
    public ProgressPointAdapter(List<SubjectInfo> mDataSource, Context mContext, int resID) {
        super(mDataSource, mContext, resID);
    }

    /**
     *  相当于RecyclerView.Adapter的onBindViewHolder方法
     */
    @Override
    protected void initView(CommonViewHolder holder, int position) {
        subjectInfo = mDataSource.get(position);
        mProgressPointView = holder.getView(R.id.tav_line);

        //根据状态设置圆圈样式
        if(subjectInfo.getState() == 0){
            mProgressPointView.setCircleShape(ProgressPointView.CENTER_CIRCLE);
            CircleTypeCheck();
        }else {
            mProgressPointView.setCircleShape(ProgressPointView.HOLLOW_CIRCLE);
        }
    }

    /**
     * 同心圆类型检查
     */
    private void CircleTypeCheck(){
        if (subjectInfo.getType() == MyListener.NO_CHOICE){
            mProgressPointView.setCircleColor(ProgressPointView.WAIT_TYPE);
        }else if (subjectInfo.getType() == MyListener.TRUE_CHOICE){
            mProgressPointView.setCircleColor(ProgressPointView.RIGHT_TYPE);
        }else {
            mProgressPointView.setCircleColor(ProgressPointView.ERROR_TYPE);
        }
    }

}
